package com.xiaoqi.lesson.controller;

import com.xiaoqi.lesson.model.UserInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

/**
 * @Author Rookie Coder
 * @Description
 * @Date
 **/
@RestController
@Slf4j
public class UserController {

    @GetMapping("/getUserInfo")
    public UserInfo getUserInfo(@RequestParam(required = false)String username,@RequestParam(required = false)String password){
        UserInfo userInfo = new UserInfo(username,password);
        return userInfo;
    }

    // 测试过滤器
    @GetMapping("/user/helloFilter")
    @ResponseBody
    public String testMyFilter(){
        return "我被监视器监视了";
    }

    // 测试登录过滤
    @GetMapping("/user/open/index")
    public String testLogin(){
      log.info("登录成功了");
        return "没有登录，也可以进来";
    }

    // 测试登录过滤
    @GetMapping("/user/notOpen/context")
    public String testNoLogin(){
        log.info("没有登录，是进不来的");
        return "没有登录，是进不来的";
    }

    // 测试登录过滤
    @GetMapping("/user/Open/hello")
    public String testThymeleaf(Model model){
        log.info("测试模板引擎");
        model.addAttribute("username","张三");
        return "hello";

    }



}
